﻿#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<iostream>
using namespace std;
#include<vector>
#include "Finish.hpp"
void test1()
{
	cout << "****** 测试用例1 ******" << endl;
	vector<int> v1{ 1,2,3,4,5,6,7,8,10 };
	cout << "** Initially ** " << endl;Print_Vector(v1,v1.size());
	
	int target = 8;
	int result = Search(v1, target);
	if(result==-1)cout << "Search Fail" << endl;
	else  cout <<"Search : "<< target << " Index = " << Search(v1, target) << endl;
	cout << "SearchInsert : " << target << " Index = " << searchInsert(v1, target) << endl;
	cout << "SearchInsert : " << target+1 << " Index = " << searchInsert(v1, target+1) << endl << endl;

	vector<int> v2{ 6,8,5,4,8,6,7,8,9 };
	cout << "** Initially ** " << endl; Print_Vector(v2, v2.size());
	int refresh_sz=removeElement(v2, 8);
	cout << "removeElement, refresh_sz = " << refresh_sz << endl;
	cout << "** Running:removeElement() **" << endl;Print_Vector(v2, refresh_sz);
	cout << endl;

	vector<int> v3{ -4,-1,0,3,10 };
	cout << "** Initially ** " << endl; Print_Vector(v3, v3.size());
	vector<int> by_v3 = sortedSquares(v3);
	cout << "** Running:sortedSquares() **" << endl; Print_Vector(by_v3, by_v3.size());
	cout << endl;

	vector<int> v4{ 1,8,5,4,8,6,7,8,9 };
	cout << "** Initially ** " << endl; Print_Vector(v4, v4.size());
	int aim = 24;
	int min_subarr_len=minSubArrayLen(aim, v4);
	cout <<"aim = "<<aim <<"; min_subarr_len = " << min_subarr_len << endl << endl;

	int arr_nn = 3;
	vector<vector<int>> vvector_nxn = generateMatrix(arr_nn);
	for (auto a : vvector_nxn)
	{
		Print_Vector(a, a.size());
	}
	cout << endl;

	vector<int> v5{ 1,1,2,3,3,3,5,6,7,7,7,7,8,10,10 };
	cout << "** Initially ** " << endl; Print_Vector(v5, v5.size());
	vector<int> ret = searchRange(v5, 1);
	cout<<"Search : "<<1<< "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 2);
	cout << "Search : " << 2 << "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 3);
	cout << "Search : " << 3 << "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 7);
	cout << "Search : " << 7 << "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 9);
	cout << "Search : " << 9 << "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 10);
	cout << "Search : " << 10 << " Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 11);
	cout << "Search : " << 11 << " Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl;
	ret = searchRange(v5, 0);
	cout << "Search : " << 0 << "  Range = " << "(" << ret[0] << "," << ret[1] << ")" << endl << endl;

	cout << 18 << " isPerfectSquare? " << isPerfectSquare(18) << endl;
	cout << 16 << " isPerfectSquare? " << isPerfectSquare(16) << endl;
	cout << "***********************" << endl<<endl;
}
void test1_1()
{
	cout << "****** 测试用例2 ******" << endl;
	int creat_n = 5;
	calcue_subarr_sum(creat_n);
	cout << endl;

	find_the_mindef_plan();
	cout << endl;
	cout << "***********************" << endl<<endl;
}	

int main()
{
	test1();
	//test1_1();//输入构建数组，计算相应要求的结果
	return 0;
}